package com.yxinsur.imc.web.controller.business;

import java.util.List;

import com.yxinsur.imc.business.domain.ImcBrokerChangeTeam;
import com.yxinsur.imc.business.form.ImcBrokerChangeTeamForm;
import com.yxinsur.imc.business.service.IImcBrokerChangeTeamService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yxinsur.imc.common.annotation.Log;
import com.yxinsur.imc.common.core.controller.BaseController;
import com.yxinsur.imc.common.core.domain.AjaxResult;
import com.yxinsur.imc.common.enums.BusinessType;

import com.yxinsur.imc.common.utils.poi.ExcelUtil;
import com.yxinsur.imc.common.core.page.TableDataInfo;

/**
 * 代理人团队异动记录Controller
 * 
 * @author imc
 * @date 2021-03-23
 */
@Api(value = "人员异动接口",tags = {"人员异动接口服务"})
@RestController
@RequestMapping("/business/changeTeam")
public class ImcBrokerChangeTeamController extends BaseController
{
    @Autowired
    private IImcBrokerChangeTeamService imcBrokerChangeTeamService;

    /**
     * 查询代理人团队异动记录列表
     */
    //@PreAuthorize("@ss.hasPermi('system:team:list')")
    @GetMapping("/list")
    public TableDataInfo list(ImcBrokerChangeTeam imcBrokerChangeTeam)
    {
        startPage();
        List<ImcBrokerChangeTeam> list = imcBrokerChangeTeamService.selectImcBrokerChangeTeamList(imcBrokerChangeTeam);
        return getDataTable(list);
    }

    /**
     * 导出代理人团队异动记录列表
     */
    //@PreAuthorize("@ss.hasPermi('system:team:export')")
    @Log(title = "代理人团队异动记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ImcBrokerChangeTeam imcBrokerChangeTeam)
    {
        List<ImcBrokerChangeTeam> list = imcBrokerChangeTeamService.selectImcBrokerChangeTeamList(imcBrokerChangeTeam);
        ExcelUtil<ImcBrokerChangeTeam> util = new ExcelUtil<ImcBrokerChangeTeam>(ImcBrokerChangeTeam.class);
        return util.exportExcel(list, "team");
    }

    /**
     * 获取代理人团队异动记录详细信息
     */
//    @PreAuthorize("@ss.hasPermi('system:team:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(imcBrokerChangeTeamService.selectImcBrokerChangeTeamById(id));
    }

    /**
     * 新增代理人团队异动记录
     */
    //@PreAuthorize("@ss.hasPermi('system:team:add')")
    @ApiOperation("代理人团队异动记录")
    @Log(title = "代理人团队异动记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ImcBrokerChangeTeamForm imcBrokerChangeTeamForm)
    {
        return toAjax(imcBrokerChangeTeamService.insertImcBrokerChangeTeam(imcBrokerChangeTeamForm));
    }

    /**
     * 修改代理人团队异动记录
     */
    @PreAuthorize("@ss.hasPermi('system:team:edit')")
    @Log(title = "代理人团队异动记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ImcBrokerChangeTeam imcBrokerChangeTeam)
    {
        return toAjax(imcBrokerChangeTeamService.updateImcBrokerChangeTeam(imcBrokerChangeTeam));
    }

    /**
     * 删除代理人团队异动记录
     */
    @PreAuthorize("@ss.hasPermi('system:team:remove')")
    @Log(title = "代理人团队异动记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(imcBrokerChangeTeamService.deleteImcBrokerChangeTeamByIds(ids));
    }
}
